- name: make the app be real
  hosts: os_control_stg[0],os_control[0]
  user: root
  gather_facts: False

  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - "/srv/private/ansible/vars.yml"
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - role: rabbit/user
    username: "fedocal{{ env_suffix }}"
    sent_topics: ^org\.fedoraproject\.{{ env_short }}\.fedocal\..*

  - role: openshift/project
    app: fedocal
    description: Fedora calendar apps
    appowners:
    - cverna
    - pingou
    - asaleh

  - role: openshift/object
    app: fedocal
    template: imagestream.yml
    objectname: imagestream.yml

  - role: openshift/object
    app: fedocal
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/secret-file
    app: fedocal
    secret_name: fedocal-fedora-messaging-key
    key: fedocal.key
    privatefile: "rabbitmq/{{env}}/pki/private/fedocal{{env_suffix}}.key"

  - role: openshift/secret-file
    app: fedocal
    secret_name: fedocal-fedora-messaging-crt
    key: fedocal.crt
    privatefile: "rabbitmq/{{env}}/pki/issued/fedocal{{env_suffix}}.crt"

  - role: openshift/secret-file
    app: fedocal
    secret_name: fedocal-fedora-messaging-ca
    key: fedocal.ca
    privatefile: "rabbitmq/{{env}}/pki/ca.crt"

  - role: openshift/object
    app: fedocal
    template: secret.yml
    objectname: secret.yml

  - role: openshift/object
    app: fedocal
    template: configmap.yml
    objectname: configmap.yml

  - role: openshift/start-build
    app: fedocal
    buildname: fedocal-build
    objectname: fedocal-build

  - role: openshift/object
    app: fedocal
    file: service.yml
    objectname: service.yml

  - role: openshift/route
    app: fedocal
    routename: fedocal
    host: "calendar{{ env_suffix }}.fedoraproject.org"
    serviceport: 8080-tcp
    servicename: fedocal

  - role: openshift/object
    app: fedocal
    file: deploymentconfig.yml
    objectname: deploymentconfig.yml

  - role: openshift/object
    app: fedocal
    file: cron.yml
    objectname: cron.yml
